const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}

var countdown = 60;
var settime = function (that) {
  if (countdown == 0) {
    that.setData({
     is_show: true
    })
    countdown = 60;
    return;
  }else {
  that.setData({
     is_show:false,
     last_time:countdown
  })
  countdown--;
 }
  setTimeout(function () {
    settime(that)
  },1000);
}

module.exports = {
  formatTime: formatTime
}
